package sms;

/**
 * Implements a SMS message that will be send to any user.
 * @author Alexandre, Cristovao, Raul, Rodolpho, Tales
 * @version 1.1
 * @milestone Number 2
 */
public class SmsMessage {

	private String from;
	private String to;
	private String message;
	private final String LINE_SEPARATOR = System.getProperty("line.separator");
	private SmsIF smsService;

	/**
	 * Sends a SMS message.
	 * @param from - the user who will send the message
	 * @param to - the user who will receives the message
	 * @param message
	 */
	public SmsMessage(String from, String to, String message) {
		this.from = from;
		this.to = to;
		this.message = message;
		this.smsService = new SmsStandardService();
	}

	/**
	 * Get the user who sent the message
	 * @return the user
	 */
	public String getFrom() {
		return from;
	}

	/**
	 * Change the user that send the message
	 * @param user
	 */
	public void setFrom(String from) {
		this.from = from;
	}

	/**
	 * Get the user who receives the message
	 * @return user
	 */
	public String getTo() {
		return to;
	}

	/**
	 * Change the user who receives the message
	 * @param user
	 */
	public void setTo(String to) {
		this.to = to;
	}

	/**
	 * Get the message that will send. 
	 * @return message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * Change the message that will sent to someone
	 * @param message
	 */
	public void setMessage(String message) {
		this.message = message;
	}
	
	/**
	 * Change the type of service that will use the SMS system.
	 * @param service
	 */
	public void setService(SmsIF service){
		this.smsService = service;
	}
	
	/**
	 * Sends the message
	 */
	public void sendMessage(){
		smsService.sendMessage(getFrom(), getTo(), getMessage());		
	}
	
	/**
	 * Get the sent SMS (formatted)
	 * @return formatted SMS
	 */
	public String getFinalMessage(){
		String finalMessage = "";
		finalMessage += "From: " + getFrom() + LINE_SEPARATOR;
		finalMessage += "to: "	+ getTo() + LINE_SEPARATOR + LINE_SEPARATOR;
		finalMessage += message + LINE_SEPARATOR;
		finalMessage += LINE_SEPARATOR
						+ "***************************************************************************************************"
						+ LINE_SEPARATOR;
		return finalMessage;
	}

}
